package Modelo;

import java.sql.Connection;
import java.sql.DriverManager;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author Peña
 */
public class Conexion {

    static Connection conexion;
    static int Puerto = 3306;
    static String Host = "localhost", DB = "punto_de_venta", Usuario = "root", Password = "123";
    static String Url = "jdbc:mysql://" + Host + ":" + Puerto + "/" + DB;

    public Conexion() {
    }

    public static Connection getConexion() {
        try {
            Class.forName("com.mysql.jdbc.Driver");

            conexion = DriverManager.getConnection(Url, Usuario, Password);
            return conexion;
        } catch (Exception e) {
            e.toString();
        }

        return null;
    }

    public static void deshacerCambios(Connection con) {
        try {
            con.rollback();
        } catch (Exception e) {
        }
    }

    public static void closeConexion() {
        try {
            conexion.close();
        } catch (Exception e) {
        }
    }
}
